﻿using King.Box.Models.Util;
using King.Box.Service;
using King.Box.WebApi.Filter;
using King.Box.WebApi.Providers.Impl;
using PsCat.Aspet;
using System.Web;
using System.Web.Http;
using System.Web.Http.ModelBinding;

namespace King.Box.WebApi.Controllers
{
#if !DEBUG
    [ClientAuthorize]
#endif
    [RoutePrefix("api/home")]
    public class HomeController : ApiController
    {
        private readonly IHomeService _homeService;

        public HomeController(IHomeService homeService)
        {
            _homeService = homeService;
        }

        #region Admin
        [HttpPost]
        [UrlCat]
        [Route("admin/login/{userName}/{pwd}")]
        public ResponseData AdminLogin(string userName, string pwd)
        {
            return _homeService.Login(userName, pwd);
        }

        [HttpPost]
        [UrlCat]
        [Route("admin/autologin/{userId}")]
        public ResponseData AutoLogin(int userId)
        {
            return _homeService.AutoLogin(userId);
        }
        #endregion
    }
}
